﻿@model ConferenceLocaleModel
@{
	Layout = null;
}
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<title>PrintView</title>
	<link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.5/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.5/themes/icon.css" />
	@Styles.Render("~/Content/css")
	@Styles.Render("~/Content/stylecss")
	@Scripts.Render("~/bundles/modernizr")
	@Scripts.Render("~/bundles/jquery")
	<script type="text/javascript" charset="utf-8" src="~/Scripts/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="~/Scripts/jquery-easyui-1.4.5/locale/@ViewBag.EasyUiLanguage"></script>
	@Scripts.Render("~/bundles/common")
	<script type="text/javascript" charset="utf-8" src="~/Scripts/layer/layer.js"></script>
	<link rel="stylesheet" type="text/css" href="~/Content/Site.css" />
	<link rel="stylesheet" type="text/css" href="~/Content/Style.css" />
	<script>
		$(function () {
			$("#barCode").attr("src", "@Url.Action(nameof(UtilityController.BarCodeImg),nameof(UtilityController).GetControllerName())" + "/@Model.AttendId");

			$("#chkIsShowName").prop("checked", @Model.IsShowName == 1 ? true : false);
			if (@Model.IsNameBold == 1) {
				$(".pName").css("font-weight", "bold");
				$("#pNameB").removeClass("localeBold");
				$("#pNameB").addClass("localeBold2");
			}
			if (@Model.IsNameOblique == 1) {
				$(".pName").css("font-style", "oblique");
				$("#pNameI").removeClass("localeItalic");
				$("#pNameI").addClass("localeItalic2");
			}
			$(".pName").css("font-size", @Model.NameSize + "px");
			$(".pName").css("margin-left", @Model.NameLeft + "px");
			$(".pName").css("margin-top", @Model.NameTop + "px");
			changeCheck("pName", @Model.IsShowName == 1 ? true : false);
			$("#hidpNameSize").val(@Model.NameSize);
			$("#hidpNameBold").val(@Model.IsNameBold);
			$("#hidpNameOblique").val(@Model.IsNameOblique);
			$("#hidpNameLeft").val(@Model.NameLeft);
			$("#hidpNameTop").val(@Model.NameTop);

			$("#chkIsShowAffiliation").prop("checked", @Model.IsShowAffiliation == 1 ? true : false);
			if (@Model.IsAffiliationBold == 1) {
				$(".pAffiliation").css("font-weight", "bold");
				$("#pAffiliationB").removeClass("localeBold");
				$("#pAffiliationB").addClass("localeBold2");
			}
			if (@Model.IsAffiliationOblique == 1) {
				$(".pAffiliation").css("font-style", "oblique");
				$("#pAffiliationI").removeClass("localeItalic");
				$("#pAffiliationI").addClass("localeItalic2");
			}
			$(".pAffiliation").css("font-size", @Model.AffiliationSize + "px");
			$(".pAffiliation").css("margin-left", @Model.AffiliationLeft + "px");
			$(".pAffiliation").css("margin-top", @Model.AffiliationTop + "px");
			changeCheck("pAffiliation", @Model.IsShowAffiliation == 1 ? true : false);
			$("#hidpAffiliationSize").val(@Model.AffiliationSize);
			$("#hidpAffiliationBold").val(@Model.IsAffiliationBold);
			$("#hidpAffiliationOblique").val(@Model.IsAffiliationOblique);
			$("#hidpAffiliationLeft").val(@Model.AffiliationLeft);
			$("#hidpAffiliationTop").val(@Model.AffiliationTop);

			$("#chkIsShowCountry").prop("checked", @Model.IsShowCountry == 1 ? true : false);
			if (@Model.IsCountryBold == 1) {
				$(".pCountry").css("font-weight", "bold");
				$("#pCountryB").removeClass("localeBold");
				$("#pCountryB").addClass("localeBold2");
			}
			if (@Model.IsCountryOblique == 1) {
				$(".pCountry").css("font-style", "oblique");
				$("#pCountryI").removeClass("localeItalic");
				$("#pCountryI").addClass("localeItalic2");
			}
			$(".pCountry").css("font-size", @Model.CountrySize + "px");
			$(".pCountry").css("margin-left", @Model.CountryLeft + "px");
			$(".pCountry").css("margin-top", @Model.CountryTop + "px");
			changeCheck("pCountry", @Model.IsShowCountry == 1 ? true : false);
			$("#hidpCountrySize").val(@Model.CountrySize);
			$("#hidpCountryBold").val(@Model.IsCountryBold);
			$("#hidpCountryOblique").val(@Model.IsCountryOblique);
			$("#hidpCountryLeft").val(@Model.CountryLeft);
			$("#hidpCountryTop").val(@Model.CountryTop);

			$("#chkIsShowBarCode").prop("checked", @Model.IsShowBarCode == 1 ? true : false);
			$("#barCode").css("width", @Model.BarCodeSize + "px");
			$(".pBarCode").css("margin-left", @Model.BarCodeLeft + "px");
			$(".pBarCode").css("margin-top", @Model.BarCodeTop + "px");
			changeCheck("pBarCode", @Model.IsShowBarCode == 1 ? true : false);
			$("#hidBarCodeSize").val(@Model.BarCodeSize);
			$("#hidpBarCodeLeft").val(@Model.BarCodeLeft);
			$("#hidpBarCodeTop").val(@Model.BarCodeTop);

			$("#chkIsShowBackground").prop("checked", @Model.IsShowBackground == 1 ? true : false);
			$("#hidPicForBackground").val("@Model.PicForBackgroundPath");
			showBackground(@Model.IsShowBackground == 1 ? true : false);

			$("#chkApply").prop("checked", false);
		})

		function changeCheck(name, value) {
			var obj = document.getElementsByClassName(name);
			if (value == true) {
				$(obj).show();
			} else {
				$(obj).hide();
			}
		}

		function changeSize(name, value) {
			var obj = document.getElementsByClassName(name);
			var oldSize = $(obj).css("font-size");
			var strInt = parseInt(oldSize.replace("px", ""));
			var newSize = value == 1 ? strInt + 1 : strInt - 1;
			$(obj).css("font-size", newSize + "px");
			$("#hid" + name + "Size").val(newSize);
		}

		function changeBold(name) {
			var obj = document.getElementsByClassName(name);
			if ($(obj).css("font-weight") == 400) {
				$(obj).css("font-weight", "bold");
				$("#" + name + "B").removeClass("localeBold");
				$("#" + name + "B").addClass("localeBold2");
				$("#hid" + name + "Bold").val(1);
			} else {
				$(obj).css("font-weight", "normal");
				$("#" + name + "B").removeClass("localeBold2");
				$("#" + name + "B").addClass("localeBold");
				$("#hid" + name + "Bold").val(0);
			}
		}

		function changeOblique(name) {
			var obj = document.getElementsByClassName(name);
			if ($(obj).css("font-style") == "normal") {
				$(obj).css("font-style", "oblique");
				$("#" + name + "I").removeClass("localeItalic");
				$("#" + name + "I").addClass("localeItalic2");
				$("#hid" + name + "Oblique").val(1);
			} else {
				$(obj).css("font-style", "normal");
				$("#" + name + "I").removeClass("localeItalic2");
				$("#" + name + "I").addClass("localeItalic");
				$("#hid" + name + "Oblique").val(0);
			}
		}

		function changePosition(name, value) {
			var obj = document.getElementsByClassName(name);
			var position;
			if (value == 1 || value == 2) {
				position = $(obj).css("margin-top");
			} else {
				position = $(obj).css("margin-left");
			}
			var strInt = parseInt(position.replace("px", ""));
			var newSize = value == 1 || value == 3 ? strInt - 1 : strInt + 1;
			if (value == 1 || value == 2) {
				$(obj).css("margin-top", newSize + "px");
				$("#hid" + name + "Top").val(newSize);
			} else {
				$(obj).css("margin-left", newSize + "px");
				$("#hid" + name + "Left").val(newSize);
			}
		}

		function changeBarCodeSize(value) {
			var oldSize = $("#barCode").css("width");
			if (oldSize != null) {
				var strInt = parseInt(oldSize.replace("px", ""));
				var newSize = value == 1 ? strInt + 10 : strInt - 10;
				if (newSize < 260) {
					$("#barCode").css("width", newSize + "px");
					$("#hidBarCodeSize").val(newSize);
				} else {
					$("#barCode").css("width", "260px");
					$("#hidBarCodeSize").val(260);
				}
			}
		}

		function showBackground(value) {
			if (value == true) {
				if ($("#hidPicForBackground").val() != "") {
					var img = $("#hidPicForBackground").val().replace("~", "");
					$(".printbox").css({
						"background-image": "url(" + img + ")",
						"background-size": "100% auto",
						"background-position": "top center",
					});
				}
			} else {
				clearBackground();
			}
		}

		function uploadBackground() {
			$("#fontChange").form({
				iframe: false,
				success: function (data) { }
			});

			$("#fontChange").form("submit", {
				url: "@Url.Action(nameof(ConferenceLocaleController.UploadBackground), nameof(ConferenceLocaleController).GetControllerName())" + "/@Model.ConferenceId",
				onSubmit: function (param) {
					param.random = Math.random();
				},
				success: function (data) {
					data = JSON.parse(data);
					if (data.result == "@ConstValues.AjaxSuccessResult") {
						$("#chkIsShowBackground").prop("checked", true);
						$("#hidPicForBackground").val(data.data);
						var img = data.data.replace("~", "");
						$(".printbox").css({
							"background-image": "url(" + img + ")",
							"background-size": "100% auto",
							"background-position": "top center",
						});
					}
				},
			});
		}

		function clearBackground() {
			$("#chkIsShowBackground").prop("checked", false);
			$(".printbox").css({
				"background-image": ""
			});
		}

		function saveData(value) {
			if (value == true) {
				$("#fontChange").form({
					iframe: false,
					success: function (data) { }
				});

				$("#fontChange").form("submit", {
					url: "@Url.Action(nameof(ConferenceLocaleController.SavePrintSetting), nameof(ConferenceLocaleController).GetControllerName())" + "/@Model.ConferenceId",
					onSubmit: function (param) {
						param.random = Math.random();
					},
					success: function (data) {
						data = JSON.parse(data);
					},
				});
			}			
		}

		function printView() {
			pagesetup_null();
			window.print();
		}

		function pagesetup_null() {
			var hkey_root, hkey_path, hkey_key;
			hkey_root = "HKEY_CURRENT_USER";
			hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
			try {
				var RegWsh = new ActiveXObject("WScript.Shell");
				hkey_key = "header";
				RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
				hkey_key = "footer";
				RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
			} catch (e) { }
		}
	</script>
</head>
<body onafterprint="window.parent.PrintViewClose();">
	<div id="printbody">
		<div class="printbox">
			<div class="printcont">
				<p class="pName">@Model.FullName</p>
				<p class="pAffiliation">@Model.Affiliation</p>
				<p class="pCountry">@Model.Country</p>
				<p class="pBarCode"><img id="barCode" /></p>
			</div>
		</div>
	</div>
	<form id="fontChange" method="post" enctype="multipart/form-data">
		@Html.AntiForgeryToken()
		<table width="100%" height="100%" cellpadding="0" cellspacing="1" border="0" class="tastyle01">
			<tr>
				<td style="text-align: center; width: 4%; background-color: #dcdcdc;">
					<input type="checkbox" id="chkIsShowName" name="IsShowName" style="vertical-align:-8px;" onchange="changeCheck('pName', this.checked);" />
				</td>
				<td style="text-align: center; width: 18%; background-color: #dcdcdc;">
					@Resources.FullName
					<input type="hidden" id="hidpNameSize" name="NameSize" />
					<input type="hidden" id="hidpNameBold" name="IsNameBold" />
					<input type="hidden" id="hidpNameOblique" name="IsNameOblique" />
					<input type="hidden" id="hidpNameLeft" name="NameLeft" />
					<input type="hidden" id="hidpNameTop" name="NameTop" />
				</td>
				<td style="text-align-last: justify; width: 15%; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeEnlarge" onclick="changeSize('pName', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeReduce" onclick="changeSize('pName', 0);"></a>
				</td>
				<td style="text-align-last: justify; width: 15%; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeBold" id="pNameB" onclick="changeBold('pName', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeItalic" id="pNameI" onclick="changeOblique('pName', 0);"></a>
				</td>
				<td style="text-align: center; width: 18%; background-color: #dcdcdc;">
					@Resources.PositionAdjust
				</td>
				<td style="text-align-last: justify; width: 30%; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeUp" onclick="changePosition('pName', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeDown" onclick="changePosition('pName', 2);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeLeft" onclick="changePosition('pName', 3);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeRight" onclick="changePosition('pName', 4);"></a>
				</td>
			</tr>
			<tr>
				<td style="text-align: center; background-color: #dcdcdc;">
					<input type="checkbox" id="chkIsShowAffiliation" name="IsShowAffiliation" style="vertical-align:-8px;" onchange="changeCheck('pAffiliation', this.checked);" />
				</td>
				<td style="text-align: center; background-color: #dcdcdc;">
					@Resources.Affiliation
					<input type="hidden" id="hidpAffiliationSize" name="AffiliationSize" />
					<input type="hidden" id="hidpAffiliationBold" name="IsAffiliationBold" />
					<input type="hidden" id="hidpAffiliationOblique" name="IsAffiliationOblique" />
					<input type="hidden" id="hidpAffiliationLeft" name="AffiliationLeft" />
					<input type="hidden" id="hidpAffiliationTop" name="AffiliationTop" />
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeEnlarge" onclick="changeSize('pAffiliation', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeReduce" onclick="changeSize('pAffiliation', 0);"></a>
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeBold" id="pAffiliationB" onclick="changeBold('pAffiliation', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeItalic" id="pAffiliationI" onclick="changeOblique('pAffiliation', 0);"></a>
				</td>
				<td style="text-align: center; background-color: #dcdcdc;">
					@Resources.PositionAdjust
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeUp" onclick="changePosition('pAffiliation', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeDown" onclick="changePosition('pAffiliation', 2);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeLeft" onclick="changePosition('pAffiliation', 3);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeRight" onclick="changePosition('pAffiliation', 4);"></a>
				</td>
			</tr>
			<tr>
				<td style="text-align: center; background-color: #dcdcdc;">
					<input type="checkbox" id="chkIsShowCountry" name="IsShowCountry" style="vertical-align:-8px;" onchange="changeCheck('pCountry', this.checked);" />
				</td>
				<td style="text-align: center; background-color: #dcdcdc;">
					@Resources.Country
					<input type="hidden" id="hidpCountrySize" name="CountrySize" />
					<input type="hidden" id="hidpCountryBold" name="IsCountryBold" />
					<input type="hidden" id="hidpCountryOblique" name="IsCountryOblique" />
					<input type="hidden" id="hidpCountryLeft" name="CountryLeft" />
					<input type="hidden" id="hidpCountryTop" name="CountryTop" />
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeEnlarge" onclick="changeSize('pCountry', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeReduce" onclick="changeSize('pCountry', 0);"></a>
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeBold" id="pCountryB" onclick="changeBold('pCountry', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeItalic" id="pCountryI" onclick="changeOblique('pCountry', 0);"></a>
				</td>
				<td style="text-align: center; background-color: #dcdcdc;">
					@Resources.PositionAdjust
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeUp" onclick="changePosition('pCountry', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeDown" onclick="changePosition('pCountry', 2);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeLeft" onclick="changePosition('pCountry', 3);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeRight" onclick="changePosition('pCountry', 4);"></a>
				</td>
			</tr>
			<tr>
				<td style="text-align: center; background-color: #dcdcdc;">
					<input type="checkbox" id="chkIsShowBarCode" name="IsShowBarCode" style="vertical-align:-8px;" onchange="changeCheck('pBarCode', this.checked);" />
				</td>
				<td style="text-align: center; background-color: #dcdcdc;">
					@Resources.BarCode
					<input type="hidden" id="hidBarCodeSize" name="BarCodeSize" />
					<input type="hidden" id="hidpBarCodeLeft" name="BarCodeLeft" />
					<input type="hidden" id="hidpBarCodeTop" name="BarCodeTop" />
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeEnlarge" onclick="changeBarCodeSize(1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeReduce" onclick="changeBarCodeSize(0);"></a>
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;"></td>
				<td style="text-align: center; background-color: #dcdcdc;" class="w1">
					@Resources.PositionAdjust
				</td>
				<td style="text-align-last: justify; background-color: #dcdcdc;">
					<a href="javascript:void(0);" class="easyui-linkbutton localeUp" onclick="changePosition('pBarCode', 1);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeDown" onclick="changePosition('pBarCode', 2);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeLeft" onclick="changePosition('pBarCode', 3);"></a>
					<a href="javascript:void(0);" class="easyui-linkbutton localeRight" onclick="changePosition('pBarCode', 4);"></a>
				</td>
			</tr>
			<tr>
				<td style="text-align: center; background-color: #dcdcdc;">
					<input type="checkbox" id="chkIsShowBackground" name="IsShowBackground" style="vertical-align:-8px;" onchange="showBackground(this.checked);" />
				</td>
				<td style="text-align: center; background-color: #dcdcdc;">@Resources.PicForCardBackground</td>
				<td style="text-align: left; background-color: #dcdcdc;" colspan="4">
					<input class="easyui-filebox" id="picForBackground" name="picForBackgroundFile" style="height:27px; width:75%;" data-options="prompt:'@Resources.UploadPicForPC', buttonText:'@Resources.ChoosePicForPC', accept: 'image/jpeg,image/png,image/gif'" />&nbsp;300*420
					<input type="hidden" id="hidPicForBackground" name="picForBackgroundPath" />
					<a href="javascript:void(0)" class="easyui-linkbutton" id="showPicForBackground" onclick="uploadBackground();">@Resources.Upload</a>
				</td>
			</tr>
		</table>
		<div style="text-align:center; font-size:16px; background-color: #dcdcdc; height:36px; line-height:36px;">
			<input type="checkbox" id="chkApply" style="vertical-align:-8px;" onchange="saveData(this.checked);" />&nbsp;&nbsp;@Resources.IsApplyAllPrint
		</div>
	</form>
	<div class="btnDiv" style="padding:20px 0">
		<input type="button" class="lbtn" onclick="printView();" value="@Resources.Print" />&nbsp;&nbsp;
		<input type="button" class="rbtn" onclick="window.parent.PrintViewClose();" value="@Resources.Close" />
	</div>
</body>
</html>